<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>毕业设计</title>
    <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet"></link>
	<script src="/js/layer/layer.js}"></script>
	<script src="/common/common.js}"></script>
    <script type="text/javascript" src="/jquery-3.3.1.min.js"></script>
    <script src="/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/js/showItems.js"></script>
</head>
<body class="gray-bg">
        <div class="wrapper wrapper-content animated fadeInRight">
        <input type="hidden" name="itemId" id="itemId" th:value="${itemId}" value="商品id"/>
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
				<form action="#" method="post">
					<div class="ibox-body">
							 <div class="form-group">
                                <label class="col-sm-3 control-label am-label-require"> 资源名称：</label>
                                <div class="col-sm-8">
                                    <input id="title" class="form-control" type="text"  autocomplete="off" value=""/>
                                </div>
                              </div>
                               <div class="form-group">
                                <label class="col-sm-3 control-label am-label-require"> 商品描述：</label>
                                <div class="col-sm-8">
                                    <input id="description" class="form-control"  type="text"  autocomplete="off" value=""/>
                                </div>
                              </div>
                              <div class="form-group" hidden="hidden">
                                <label class="col-sm-3 control-label am-label-require"> 商品图片：</label>
                                <div class="col-sm-8">
                                    <input id="imgUrl" class="form-control"  type="text"  autocomplete="off" value=""/>
                                </div>
                              </div> 
                               <div class="form-group">
                                <label class="col-sm-3 control-label am-label-require"> 价 格：</label>
                                <div class="col-sm-8">
                                    <input id="price" class="form-control"  type="text"  autocomplete="off" value=""/>
                                </div>
                              </div>
                              <div class="form-group">
                                <label class="col-sm-3 control-label am-label-require" > 销 量：</label>
                                <div class="col-sm-8">
                                    <input id="titleSales" class="form-control" readonly="readonly"  type="text"  autocomplete="off" value=""/>
                                </div>
                              </div>
							
							  <div class="form-group">
	                            <label class="col-sm-3 control-label am-label-require"> 库 存：</label>
                                <div class="col-sm-8">
                                    <input id="titleStock" class="form-control"  type="text" autocomplete="off" value=""/>
                                </div>
                               </div>
						</div>
					</form>
					</div>
				</div>
			</div>
			<br>
				<div align="center">
					<button class="button button-pill" onclick="upItem()" style="width: 55px;height: 35px" >修改</button>&nbsp;&nbsp;&nbsp;
		            <button class="button button-pill" onclick="reset()" style="width: 55px;height: 35px;" >取消</button>
	            </div>
	</div>
</body>

<script type="text/javascript">
//定义全局商品信息数组
jQuery(document).ready(function(){
	var id = $("#itemId").val();
	$.ajax({
        url: "/selItem?id="+id,
        type: "GET",
        cache: false,
        success: function (data) {  
        	if (data.status == "success") {
                //获取成功的操作
        		itemBo=data.data;
        		reloadDom();
             } else {
             	alert("获取商品信息失败,原因为: "+data.data);
             }
        }
    })
    
    function reloadDom(){
		 $("#title").val(itemBo.title);
         $("#description").val(itemBo.description);
         $("#imgUrl").val(itemBo.imgUrl);
         $("#titleStock").val(itemBo.stock);
         $("#price").val(itemBo.price);
         $("#titleSales").val(itemBo.sales);
         $("#titleStock").val(itemBo.stock);
	}
})


//撤销修改
function reset() {
	var index = parent.layer.getFrameIndex(window.name);
	parent.layer.close(index);
}

</script>

</html>
